using UnityEngine;
using System.Collections;

public class Rat : MonoBehaviour {
	
	#region Variables
	
	#region Numbers
	
	//Used as a counter for when the rat is outside the cameras range
	private int cameraBounds; 
	
	public static int fuck;
	//Random number used to see if there will be a mouse appearing on the screen
	float dice;	
	

	#endregion
	
	#region Vectors
	
	//Saves the rats point of origin
	Vector3 ratPosition; 
	
	#endregion
	
	#region Booleans
	
	//While true the rat will be moving other wise it will toss a dice to see if he will
	public static bool ratMove;
		
	#endregion
	
	#endregion
	// Use this for initialization
	void Start () {
		
	//Saving starting position
		ratPosition = transform.position; 
		
	//Sets the movement of the rat to false to start out throwing the dice
		ratMove=false; 
	}
	
	// Update is called once per frame
	void Update () {
		
	//Code for dice
		if(!ratMove){	
			dice= Random.Range(0,100);
			fuck=0;
	//If thrown dice is 4 it will exit this loop and go to the movement code
			if(dice == 4){
				ratMove=true;
			}
	//Code for movement
		}else if(ratMove){  
			fuck=1;
			
	//Moves the rat
			transform.Translate(new Vector3(0.3f,0f,0)); 
			
	//Counter incremental		
			cameraBounds++; 
			
	/* If counter is at 125 (or could be set for when rat is outside visible range)
	 * the rats position will be reset to begining or the vector for the saved variable
	 * boolean for rat movement will be reset and dice will start being thrown again and
	 * counter will be reset
	 */
			if(cameraBounds == 125){ 
				transform.position = ratPosition; 
				ratMove = false;
				cameraBounds=0;
			}
		} //}else if(ratMove){ 
		
	//Just to make sure there are no errors dice gets reset once per frame
		dice=0;
	
		
	}		
				
}
